<template>
	<view class="page">
		<view class="">
			<!-- 优惠卷 -->
			<u-tabs  :list="tabbar" :current="current" @change="change" font-size="28" bar-width="110"
				bar-height="4" bg-color="#fff" active-color="#00C08D" :is-scroll="false" inactive-color="#333333">
			</u-tabs>
		</view>
		
		<wr-coupon v-for="(item,index) in list" @tap="getCoupon(item) " :item="item" :status="current"> </wr-coupon>
		
		
	    <u-loadmore :status="initial.status" />
	</view>
</template>

<script>
	import loader from '@/common/loadPage.js';
	export default {
		mixins: [loader],
		data() {
			return {
			
				tabbar: [ {
					name: '待领取'
				}, {
					name: '未使用',
				}, {
					name: '已使用',
				}],
				nav: [],
				current: 0,
				list: [],
				initial: {
					geturl: "/coupon/index",
					parm: {
					    is_no_get:1
					},
					isPage: true
				},




			}
		},
		async onLoad() {
			this.getGoods()
		},
		methods: {
			getCoupon(item){
				if(this.current)return
				this.$u.post('/coupon/getCoupon', {
					coupon_id:item.coupon_id
				}).then(res => {
				     this.$u.toast("领取成功")
					 this.initial.page=1;
					 this.initial.geturl="/coupon/index"
					 this.initial.parm.is_no_get=1
					 this.getGoods()
				}).catch(err => {})
				
			},
			
			
			
			change(e){
				this.initial.page=1;
				this.current=e;
				if(e==0){
					this.initial.geturl="/coupon/index";
					this.initial.parm.is_no_get=1
				}
				if(e==1){
					this.initial.geturl="/coupon/isUse"
					this.initial.parm.is_use=0
				}
				
				if(e==2){
					this.initial.geturl="/coupon/isUse"
					this.initial.parm.is_use=1
				}
				this.getGoods()
			}
			
		}
	}
</script>


<style>
	.page {
		background: #F1F1F1;
		min-height: 100vh;
	}
	.list{
		background: #fff;
	    width:700rpx;
		 margin: 20rpx auto;
		 padding: 20rpx;
	}
</style>
